package com.ideaaedi.zoo.example.springboot.flowable.sharding.controller.helper.entity.enums;

import com.ideaaedi.zoo.commonbase.enums.EnumDescriptor;
import com.ideaaedi.zoo.example.springboot.flowable.sharding.controller.helper.entity.NextNodeProvider;

import javax.annotation.Nullable;
import java.util.Set;

/**
 * 请假审批状态
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img
 * src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 1.0.0
 */
public enum LeaveApprovalState implements EnumDescriptor, NextNodeProvider<LeaveApprovalState> {
    DRAFT("草稿"),
    TO_AUDIT("待审批"),
    AUDIT_PASS("审批通过"),
    REVIEW_PASS("领导复审通过"),
    AUDIT_REJECT("审批不通过"),
    REVIEW_REJECT("复审不通过");
    
    /**
     * 描述
     */
    private final String desc;
    
    LeaveApprovalState(String desc) {
        this.desc = desc;
    }
    
    @Override
    public String obtainDescription() {
        return this.desc;
    }
    
    @Override
    @Nullable
    public Set<LeaveApprovalState> nextNodes() {
        switch (this) {
            case DRAFT -> {
                return Set.of(TO_AUDIT);
            }
            case TO_AUDIT -> {
                return Set.of(AUDIT_PASS, AUDIT_REJECT);
            }
            case AUDIT_PASS -> {
                return Set.of(REVIEW_PASS, REVIEW_REJECT);
            }
        }
        return null;
    }
}
